<template>
    <input  v-model="textValue" :type="type" @click="handleClick" @blur="handleBlur"/>
</template>

<script>
    export default {
        props:{
            value:{default:""},
            type:{default:"text"}
        },
        name: "",
        data(){
            return {
                textValue: this.value || '',
            }
        },
        methods: {
            handleClick(){
                //通知父组件更新值
                this.$emit("input",this.textValue);
                //通知父组件校验
                this.$parent.$emit('validate', this.inputValue)
            },
            handleBlur(){
                //通知父组件更新值
                this.$emit("input",this.textValue);
                //通知父组件校验
                this.$parent.$emit('validate', this.inputValue)
            }
        }
    }
</script>

<style scoped>

</style>